package com.muse.springbootdemo.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import com.muse.springbootdemo.service.ProducerService;

import lombok.extern.slf4j.Slf4j;

/**
 * @description
 * @author: muse
 **/
@Slf4j
@RestController
public class KafkaController {

    @Resource
    private ProducerService producerService;

    /**
     * http://localhost:9000/blockingSendMsg
     */
    @GetMapping("/blockingSendMsg")
    public String blockingSendMsg() {
        try {
            producerService.blockingSendMsg();
        } catch (Throwable throwable) {
            log.error("KafkaController.blockingSendMsg error!", throwable);
        }
        return "KafkaController.blockingSendMsg Success!";
    }

    /**
     * http://localhost:9000/noBlockingSendMsg
     */
    @GetMapping("/noBlockingSendMsg")
    public String pushMessge() {
        try {
            producerService.noBlockingSendMsg();
        } catch (Throwable throwable) {
            log.error("KafkaController.noBlockingSendMsg error!", throwable);
        }
        return "KafkaController.noBlockingSendMsg Success!";
    }


}
